******** The following analyses were carried out using Stata 16.1. **************
clear
* install  eststo ivreg2
* set working directory
cd ""

import delimited "FixedAssets&Corruption.csv", case(preserve) clear

#delimit ;
macro define covars1 "marketsize growthrate lscale soe_influence 
               mgovthelp mtaxrate soe collective private foreign 
               lage lemp sales_otherprov govtsales 
               soesales relationship licenses interaction";
#delimit cr

#delimit ;
macro define indcovars1 "marketsize growthrate lscale soe_influence 
               mgovthelp mtaxrate";
#delimit cr


destring lintensity_investment_employment lnle_fix_emp_mean ///
    LSC TrustCourts BI_mc enforce lceopay gm_govt  hhi w_con_sal4 ///
    $covars1 , force replace

lab var marketsize "Market Size"
lab var growthrate "Growth Rate"
lab var lscale "Scale Economies (log)"
lab var soe_influence "SOE Dominance"
lab var mgovthelp "Government Help"
lab var mtaxrate "Tax Burden"
lab var soe "SOE"
lab var collective "Collective"
lab var private "Private"
lab var foreign "Foreign"
lab var lage "Age (log)"
lab var lemp "Employees (log)"
lab var sales_otherprov "Out-of-Province Sales"
lab var govtsales "Proportion of Sales to Government"
lab var soesales "Proportion of Sales to SOEs"
lab var relationship "Years of Relationship"
lab var licenses "Licenses"
lab var interaction "Interaction with Government"
lab var lceopay "CEO Pay (log)"
lab var gm_govt "Government Appointed General Manager"
lab var gdpper_1999_2003 "GDP per Capita (log)"
lab var pop "Population"
lab var LSC "LSC"
lab var TrustCourts "Trust in Courts"
lab var BI_mc "Bureaucratic Integration"
lab var enforce "Enforcement (Factor Scores)"
lab var w_con_sal4 "Market Concentration (CR4)"
lab var hhi "Market Concentration (HHI)"
lab var lnle_fix_emp_mean "FAI (China)"


xtset provinceidx 

macro define output1 "label b(3) se(3) tex nogap nomti"

********************************************************************************
* China FAI
* Table A: First Stage Regression
eststo first: xi: reg lnle_fix_emp_mean lintensity_investment_employment  ///
      $indcovars1 i.provinceidx if dup_ind_first==1

test lintensity_investment_employment


********************************************************************************
* Table B: Fixed-Asset Intensity and Firms’ ETCs (IV Estimation)

predict faihat, xb
lab var faihat "FAI (China)"

#delimit ;
eststo base1: bootstrap _b, strata(prov_ind) rep(1000) seed(977060) reject(e(converged)==0):
xtreg letcs c.faihat $covars1, fe; 

#delimit ;
eststo base2: bootstrap _b, strata(prov_ind) rep(1000) seed(977060) reject(e(converged)==0):
xtreg letcs c.faihat $covars1 lceopay, fe; 

#delimit ;
eststo base3: bootstrap _b, strata(prov_ind) rep(1000) seed(977060) reject(e(converged)==0):
xtreg letcs c.faihat $covars1 gm_govt, fe; 

esttab base1 base2 base3 using table1.tex, ///
$output1 stats(N, fmt(0) labels("\textit{N}")) star(* 0.10 ** 0.05 *** 0.01) replace

* Table C: Fixed-Asset Intensity, Market Concentration, and Firms’ ETCs (IV Estimation)
eststo Mediation1: xi: ivreg2 w_con_sal4 (lnle_fix_emp_mean=lintensity_investment_employment) marketsize ///
       growthrate lscale soe_influence mgovthelp mtaxrate i.provinceidx if dup_ind_first==1, gmm ffirst

#delimit ;
eststo Mediation2: bootstrap _b, strata(prov_ind) rep(1000) seed(977060) reject(e(converged)==0):
xtreg letcs c.faihat w_con_sal4 $covars1, fe; 

eststo Mediation3: xi: ivreg2 hhi (lnle_fix_emp_mean=lintensity_investment_employment) marketsize ///
       growthrate lscale soe_influence mgovthelp mtaxrate i.provinceidx if dup_ind_first==1,  gmm ffirst

#delimit ;
eststo Mediation4: bootstrap _b, strata(prov_ind) rep(1000) seed(977060) reject(e(converged)==0):
xtreg letcs c.faihat hhi $covars1, fe; 

********************************************************************************
* Table D: Fixed-Asset Intensity, Enforcement of the Law, and Firms’ ETCs (IV MLMs)
*LSC
#delimit ;
eststo interaction1: bootstrap _b, strata(prov_ind) rep(1000) seed(977060) reject(e(converged)==0):
mixed letcs c.faihat##c.LSC $covars1  gdpper_1999_2003 pop||provinceidx: ; 

*TrustCourts
#delimit ;
eststo interaction2: bootstrap _b, strata(prov_ind) rep(1000) seed(977060) reject(e(converged)==0):
mixed letcs c.faihat##c.TrustCourts $covars1  gdpper_1999_2003 pop||provinceidx: ; 

*BI
#delimit ;
eststo interaction3: bootstrap _b, strata(prov_ind) rep(1000) seed(977060) reject(e(converged)==0):
mixed letcs c.faihat##c.BI_mc $covars1  gdpper_1999_2003 pop||provinceidx: ; 

*enforce
#delimit ;
eststo interaction4: bootstrap _b, strata(prov_ind) rep(1000) seed(977060) reject(e(converged)==0):
mixed letcs c.faihat##c.enforce $covars1  gdpper_1999_2003 pop||provinceidx: ; 

